<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/1/26
 * Time: 15:08
 */

namespace app\api\service;


use app\common\model\UserCollection;

class Collection
{
    static function add($param)
    {
        $coll = UserCollection::get(["goods_id" => $param["goods_id"],"community_id" => $param["community_id"]]);
        if (!$coll) {
            return UserCollection::create($param);
        }
        return false;
    }

    static function del($param)
    {
        return UserCollection::destroy($param);
    }

    static function list_($param)
    {
        $i_data = UserCollection::all(function ($query) use ($param) {
            $query->join("shop_goods", "shop_goods.id = shop_user_collection.goods_id")->where($param);
        });
        return $i_data;
    }
}